package com.itheima.edu.info.manager.day11;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Arrays;

public class Test {
    public static void main(String[] args) throws IOException {
        File file = new File("D://jinjie//实验");
        File file3 = new File("D:/");
        file.mkdirs();
        File file1 = new File("D://jinjie//实验//ccc");
        File file2 = new File("D://jinjie//实验//ccc//ccc.txt");
        file1.mkdirs();
        file2.createNewFile();
        boolean delete = file.delete();
        System.out.println(delete);
        File f = new File("D://jinjie//bbb");
        File f1 = new File("D://jinjie//aaa");
        File f2 = new File("D://jinjie//bbb.exe");
        boolean fFile = f.isFile();
        System.out.println(fFile);
        boolean exists = f1.exists();
        System.out.println(exists);
        File[] listFiles = file3.listFiles();
        System.out.println("------------");
        System.out.println(Arrays.toString(file3.listFiles()));
        System.out.println(Arrays.toString(listFiles));
        boolean directory = f2.isDirectory();
        System.out.println(directory);
        File f4 = new File(file, "BBB");
        File f8 = new File(file, "BBBc");
        File f7 = new File(file, "BBBd");
        File f6 = new File(file, "BBBe");
        File f5 = new File(file, "BBBa");
        f4.mkdirs();
        f8.mkdirs();
        f7.mkdirs();
        f6.mkdirs();
        f5.mkdirs();
        File file5 = new File(f4, "a.exe");
        File file6 = new File(f4, "b.exe");
        File file7 = new File(f4, "d.exe");
        File file8 = new File(f4, "e.exe");
        file5.createNewFile();
        file6.createNewFile();
        file7.createNewFile();
        file8.createNewFile();
        digui(file);

    }

    private static void digui(File file) {
//        if(file.exists()){//错误代码exists是判断该文件夹是否存在
//            file.delete();
        //    }
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()) {
                file1.delete();
            } else {
                digui(file1);
            }
        }
        file.delete();
    }
}
